{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Regressão Linear Multivariada - Trabalho\n",
    "\n",
    "## Estudo de caso: Qualidade de Vinhos\n",
    "\n",
    "Nesta trabalho, treinaremos um modelo de regressão linear usando descendência de gradiente estocástico no conjunto de dados da Qualidade do Vinho. O exemplo pressupõe que uma cópia CSV do conjunto de dados está no diretório de trabalho atual com o nome do arquivo *winequality-white.csv*.\n",
    "\n",
    "O conjunto de dados de qualidade do vinho envolve a previsão da qualidade dos vinhos brancos em uma escala, com medidas químicas de cada vinho. É um problema de classificação multiclasse, mas também pode ser enquadrado como um problema de regressão. O número de observações para cada classe não é equilibrado. Existem 4.898 observações com 11 variáveis de entrada e 1 variável de saída. Os nomes das variáveis são os seguintes:\n",
    "\n",
    "1. Fixed acidity.\n",
    "2. Volatile acidity.\n",
    "3. Citric acid.\n",
    "4. Residual sugar.\n",
    "5. Chlorides.\n",
    "6. Free sulfur dioxide. \n",
    "7. Total sulfur dioxide. \n",
    "8. Density.\n",
    "9. pH.\n",
    "10. Sulphates.\n",
    "11. Alcohol.\n",
    "12. Quality (score between 0 and 10).\n",
    "\n",
    "O desempenho de referencia de predição do valor médio é um RMSE de aproximadamente 0.148 pontos de qualidade.\n",
    "\n",
    "Utilize o exemplo apresentado no tutorial e altere-o de forma a carregar os dados e analisar a acurácia de sua solução. \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "            0         1         2         3         4         5         6   \\\n",
      "0     0.307692  0.186275  0.216867  0.308282  0.106825  0.149826  0.373550   \n",
      "1     0.240385  0.215686  0.204819  0.015337  0.118694  0.041812  0.285383   \n",
      "2     0.413462  0.196078  0.240964  0.096626  0.121662  0.097561  0.204176   \n",
      "3     0.326923  0.147059  0.192771  0.121166  0.145401  0.156794  0.410673   \n",
      "4     0.326923  0.147059  0.192771  0.121166  0.145401  0.156794  0.410673   \n",
      "5     0.413462  0.196078  0.240964  0.096626  0.121662  0.097561  0.204176   \n",
      "6     0.230769  0.235294  0.096386  0.098160  0.106825  0.097561  0.294664   \n",
      "7     0.307692  0.186275  0.216867  0.308282  0.106825  0.149826  0.373550   \n",
      "8     0.240385  0.215686  0.204819  0.015337  0.118694  0.041812  0.285383   \n",
      "9     0.413462  0.137255  0.259036  0.013804  0.103858  0.090592  0.278422   \n",
      "10    0.413462  0.186275  0.246988  0.013037  0.071217  0.031359  0.125290   \n",
      "11    0.461538  0.147059  0.240964  0.055215  0.077151  0.052265  0.232019   \n",
      "12    0.394231  0.098039  0.222892  0.009202  0.091988  0.048780  0.153132   \n",
      "13    0.269231  0.078431  0.240964  0.013804  0.103858  0.160279  0.310905   \n",
      "14    0.432692  0.333333  0.373494  0.286043  0.091988  0.135889  0.378190   \n",
      "15    0.269231  0.088235  0.228916  0.013804  0.068249  0.090592  0.238979   \n",
      "16    0.240385  0.392157  0.024096  0.007669  0.109792  0.097561  0.208817   \n",
      "17    0.230769  0.568627  0.289157  0.009202  0.059347  0.094077  0.153132   \n",
      "18    0.346154  0.254902  0.253012  0.007669  0.071217  0.052265  0.375870   \n",
      "19    0.259615  0.225490  0.084337  0.105828  0.103858  0.111498  0.287703   \n",
      "20    0.230769  0.568627  0.289157  0.009202  0.059347  0.094077  0.153132   \n",
      "21    0.250000  0.225490  0.228916  0.035276  0.086053  0.059233  0.215777   \n",
      "22    0.288462  0.176471  0.253012  0.016871  0.118694  0.135889  0.262181   \n",
      "23    0.365385  0.578431  0.084337  0.013804  0.192878  0.080139  0.368910   \n",
      "24    0.269231  0.186275  0.246988  0.010736  0.127596  0.048780  0.308585   \n",
      "25    0.307692  0.166667  0.192771  0.128834  0.109792  0.188153  0.547564   \n",
      "26    0.298077  0.156863  0.210843  0.006135  0.127596  0.114983  0.317865   \n",
      "27    0.307692  0.196078  0.234940  0.124233  0.124629  0.104530  0.306265   \n",
      "28    0.346154  0.186275  0.289157  0.007669  0.112760  0.052265  0.285383   \n",
      "29    0.326923  0.235294  0.216867  0.021472  0.071217  0.121951  0.243619   \n",
      "...        ...       ...       ...       ...       ...       ...       ...   \n",
      "4868  0.192308  0.147059  0.186747  0.059816  0.109792  0.139373  0.266821   \n",
      "4869  0.269231  0.156863  0.198795  0.145706  0.068249  0.020906  0.167053   \n",
      "4870  0.221154  0.235294  0.168675  0.092025  0.035608  0.094077  0.285383   \n",
      "4871  0.115385  0.117647  0.240964  0.019939  0.017804  0.062718  0.206497   \n",
      "4872  0.211538  0.333333  0.246988  0.180982  0.068249  0.167247  0.394432   \n",
      "4873  0.182692  0.127451  0.192771  0.015337  0.062315  0.108014  0.262181   \n",
      "4874  0.173077  0.117647  0.216867  0.029141  0.115727  0.048780  0.269142   \n",
      "4875  0.346154  0.137255  0.156627  0.009202  0.077151  0.055749  0.204176   \n",
      "4876  0.230769  0.294118  0.253012  0.029141  0.086053  0.111498  0.250580   \n",
      "4877  0.201923  0.450980  0.000000  0.003067  0.068249  0.034843  0.169374   \n",
      "4878  0.230769  0.441176  0.012048  0.004601  0.077151  0.013937  0.167053   \n",
      "4879  0.269231  0.254902  0.240964  0.115031  0.109792  0.229965  0.373550   \n",
      "4880  0.269231  0.254902  0.240964  0.115031  0.109792  0.229965  0.373550   \n",
      "4881  0.115385  0.151961  0.162651  0.171012  0.062315  0.111498  0.252900   \n",
      "4882  0.163462  0.235294  0.078313  0.010736  0.083086  0.149826  0.341067   \n",
      "4883  0.105769  0.382353  0.102410  0.019939  0.077151  0.202091  0.322506   \n",
      "4884  0.259615  0.245098  0.228916  0.118098  0.115727  0.229965  0.382831   \n",
      "4885  0.269231  0.254902  0.240964  0.115031  0.109792  0.229965  0.373550   \n",
      "4886  0.230769  0.127451  0.168675  0.078221  0.056380  0.149826  0.259861   \n",
      "4887  0.230769  0.323529  0.132530  0.019939  0.041543  0.010453  0.109049   \n",
      "4888  0.288462  0.137255  0.216867  0.009202  0.127596  0.125436  0.273782   \n",
      "4889  0.105769  0.151961  0.162651  0.171012  0.062315  0.111498  0.252900   \n",
      "4890  0.221154  0.254902  0.174699  0.024540  0.080119  0.080139  0.211137   \n",
      "4891  0.182692  0.127451  0.192771  0.004601  0.086053  0.125436  0.259861   \n",
      "4892  0.259615  0.147059  0.228916  0.010736  0.068249  0.094077  0.238979   \n",
      "4893  0.230769  0.127451  0.174699  0.015337  0.089021  0.076655  0.192575   \n",
      "4894  0.269231  0.235294  0.216867  0.113497  0.112760  0.191638  0.368910   \n",
      "4895  0.259615  0.156863  0.114458  0.009202  0.094955  0.097561  0.236659   \n",
      "4896  0.163462  0.205882  0.180723  0.007669  0.038576  0.062718  0.234339   \n",
      "4897  0.211538  0.127451  0.228916  0.003067  0.032641  0.069686  0.206497   \n",
      "\n",
      "            7         8         9         10        11  \n",
      "0     0.267785  0.254545  0.267442  0.129032  0.500000  \n",
      "1     0.132832  0.527273  0.313953  0.241935  0.500000  \n",
      "2     0.154039  0.490909  0.255814  0.338710  0.500000  \n",
      "3     0.163678  0.427273  0.209302  0.306452  0.500000  \n",
      "4     0.163678  0.427273  0.209302  0.306452  0.500000  \n",
      "5     0.154039  0.490909  0.255814  0.338710  0.500000  \n",
      "6     0.150183  0.418182  0.290698  0.258065  0.500000  \n",
      "7     0.267785  0.254545  0.267442  0.129032  0.500000  \n",
      "8     0.132832  0.527273  0.313953  0.241935  0.500000  \n",
      "9     0.128976  0.454545  0.267442  0.483871  0.500000  \n",
      "10    0.071139  0.245455  0.395349  0.645161  0.333333  \n",
      "11    0.146327  0.381818  0.360465  0.274194  0.333333  \n",
      "12    0.094274  0.418182  0.476744  0.451613  0.333333  \n",
      "13    0.078851  0.745455  0.348837  0.709677  0.666667  \n",
      "14    0.252362  0.236364  0.523256  0.274194  0.333333  \n",
      "15    0.082707  0.481818  0.383721  0.548387  0.666667  \n",
      "16    0.109697  0.472727  0.162791  0.258065  0.500000  \n",
      "17    0.040293  0.554545  0.197674  0.774194  0.833333  \n",
      "18    0.088490  0.363636  0.360465  0.532258  0.500000  \n",
      "19    0.161751  0.454545  0.325581  0.241935  0.333333  \n",
      "20    0.040293  0.554545  0.197674  0.774194  0.833333  \n",
      "21    0.078851  0.409091  0.151163  0.483871  0.666667  \n",
      "22    0.113553  0.681818  0.302326  0.403226  0.833333  \n",
      "23    0.127048  0.300000  0.337209  0.209677  0.333333  \n",
      "24    0.154039  0.636364  0.290698  0.322581  0.500000  \n",
      "25    0.161751  0.481818  0.325581  0.387097  0.500000  \n",
      "26    0.113553  0.663636  0.255814  0.322581  0.500000  \n",
      "27    0.173318  0.600000  0.360465  0.403226  0.500000  \n",
      "28    0.082707  0.427273  0.313953  0.580645  0.500000  \n",
      "29    0.067284  0.345455  0.569767  0.693548  0.666667  \n",
      "...        ...       ...       ...       ...       ...  \n",
      "4868  0.118180  0.536364  0.488372  0.451613  0.500000  \n",
      "4869  0.176403  0.427273  0.337209  0.290323  0.500000  \n",
      "4870  0.091961  0.390909  0.162791  0.556452  0.666667  \n",
      "4871  0.049933  0.590909  0.383721  0.653226  0.500000  \n",
      "4872  0.175631  0.381818  0.441860  0.274194  0.333333  \n",
      "4873  0.064199  0.554545  0.348837  0.629032  0.500000  \n",
      "4874  0.110083  0.700000  0.313953  0.322581  0.500000  \n",
      "4875  0.102950  0.363636  0.220930  0.274194  0.500000  \n",
      "4876  0.081164  0.581818  0.430233  0.580645  0.666667  \n",
      "4877  0.110854  0.481818  0.162791  0.129032  0.333333  \n",
      "4878  0.100829  0.472727  0.151163  0.241935  0.166667  \n",
      "4879  0.150954  0.390909  0.325581  0.247312  0.500000  \n",
      "4880  0.150954  0.390909  0.325581  0.247312  0.500000  \n",
      "4881  0.159823  0.318182  0.325581  0.225806  0.500000  \n",
      "4882  0.091190  0.490909  0.186047  0.435484  0.333333  \n",
      "4883  0.048776  0.500000  0.151163  0.564516  0.500000  \n",
      "4884  0.150569  0.381818  0.325581  0.258065  0.333333  \n",
      "4885  0.150954  0.390909  0.325581  0.250000  0.500000  \n",
      "4886  0.088105  0.445455  1.000000  0.669355  0.666667  \n",
      "4887  0.041835  0.290909  0.662791  0.806452  0.666667  \n",
      "4888  0.119337  0.290909  0.372093  0.193548  0.333333  \n",
      "4889  0.159823  0.318182  0.325581  0.225806  0.500000  \n",
      "4890  0.043763  0.309091  0.255814  0.612903  0.500000  \n",
      "4891  0.069983  0.472727  0.279070  0.419355  0.500000  \n",
      "4892  0.113168  0.518182  0.372093  0.274194  0.333333  \n",
      "4893  0.077694  0.500000  0.325581  0.516129  0.500000  \n",
      "4894  0.150183  0.390909  0.279070  0.258065  0.333333  \n",
      "4895  0.104685  0.245455  0.279070  0.225806  0.500000  \n",
      "4896  0.030461  0.563636  0.186047  0.774194  0.666667  \n",
      "4897  0.044342  0.490909  0.116279  0.612903  0.500000  \n",
      "\n",
      "[4898 rows x 12 columns]\n"
     ]
    }
   ],
   "source": [
    "### Importar o dataset\n",
    "\n",
    "import pandas as pd\n",
    "from sklearn.model_selection import train_test_split\n",
    "import numpy\n",
    "\n",
    "dataset = pd.read_csv('winequality-white.csv', sep=';')\n",
    "\n",
    "### Normalizar dados\n",
    "\n",
    "from sklearn import preprocessing\n",
    "\n",
    "x = dataset.values #returns a numpy array\n",
    "min_max_scaler = preprocessing.MinMaxScaler()\n",
    "x_scaled = min_max_scaler.fit_transform(x)\n",
    "dataset = pd.DataFrame(x_scaled)\n",
    "print(dataset)\n",
    "\n",
    "### Separar dados de treino e dados de teste\n",
    "\n",
    "X = dataset.iloc[:, :11]\n",
    "y = dataset.iloc[:, 11:]\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)\n",
    "\n",
    "X_train = X_train.values\n",
    "X_test = X_test.values\n",
    "y_train = y_train.values\n",
    "y_test = y_test.values\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "### Definição das funções da regressão linear multivariada\n",
    "\n",
    "def predict(row, coefficients):\n",
    "  yhat = coefficients[0]\n",
    "  for i in range(len(row)-1):\n",
    "    yhat += coefficients[i + 1] * row[i]\n",
    "  return yhat\n",
    "\n",
    "def coefficients_sgd(train, l_rate, n_epoch):\n",
    "    coef = [0.0 for i in range(len(train[0]))]\n",
    "    print ('Coeficiente Inicial={0}' % (coef))\n",
    "    for epoch in range(n_epoch):\n",
    "        sum_error = 0\n",
    "        for row in train:\n",
    "            yhat = predict(row, coef)\n",
    "            error = yhat - row[-1]\n",
    "            sum_error += error**2\n",
    "            coef[0] = coef[0] - l_rate * error\n",
    "            for i in range(len(row)-1):\n",
    "                coef[i + 1] = coef[i + 1] - l_rate * error * row[i] \n",
    "        print(('epoch=%d, lrate=%.3f, error=%.3f' % (epoch, l_rate, sum_error/n_epoch)))\n",
    "    return coef"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Coeficiente Inicial={0}\n",
      "epoch=0, lrate=0.010, error=0.852\n",
      "epoch=1, lrate=0.010, error=0.624\n",
      "epoch=2, lrate=0.010, error=0.536\n",
      "epoch=3, lrate=0.010, error=0.488\n",
      "epoch=4, lrate=0.010, error=0.457\n",
      "epoch=5, lrate=0.010, error=0.436\n",
      "epoch=6, lrate=0.010, error=0.419\n",
      "epoch=7, lrate=0.010, error=0.405\n",
      "epoch=8, lrate=0.010, error=0.393\n",
      "epoch=9, lrate=0.010, error=0.382\n",
      "epoch=10, lrate=0.010, error=0.372\n",
      "epoch=11, lrate=0.010, error=0.363\n",
      "epoch=12, lrate=0.010, error=0.355\n",
      "epoch=13, lrate=0.010, error=0.347\n",
      "epoch=14, lrate=0.010, error=0.340\n",
      "epoch=15, lrate=0.010, error=0.333\n",
      "epoch=16, lrate=0.010, error=0.326\n",
      "epoch=17, lrate=0.010, error=0.320\n",
      "epoch=18, lrate=0.010, error=0.313\n",
      "epoch=19, lrate=0.010, error=0.307\n",
      "epoch=20, lrate=0.010, error=0.302\n",
      "epoch=21, lrate=0.010, error=0.296\n",
      "epoch=22, lrate=0.010, error=0.291\n",
      "epoch=23, lrate=0.010, error=0.285\n",
      "epoch=24, lrate=0.010, error=0.280\n",
      "epoch=25, lrate=0.010, error=0.275\n",
      "epoch=26, lrate=0.010, error=0.270\n",
      "epoch=27, lrate=0.010, error=0.266\n",
      "epoch=28, lrate=0.010, error=0.261\n",
      "epoch=29, lrate=0.010, error=0.257\n",
      "epoch=30, lrate=0.010, error=0.252\n",
      "epoch=31, lrate=0.010, error=0.248\n",
      "epoch=32, lrate=0.010, error=0.244\n",
      "epoch=33, lrate=0.010, error=0.240\n",
      "epoch=34, lrate=0.010, error=0.236\n",
      "epoch=35, lrate=0.010, error=0.232\n",
      "epoch=36, lrate=0.010, error=0.229\n",
      "epoch=37, lrate=0.010, error=0.225\n",
      "epoch=38, lrate=0.010, error=0.221\n",
      "epoch=39, lrate=0.010, error=0.218\n",
      "epoch=40, lrate=0.010, error=0.215\n",
      "epoch=41, lrate=0.010, error=0.211\n",
      "epoch=42, lrate=0.010, error=0.208\n",
      "epoch=43, lrate=0.010, error=0.205\n",
      "epoch=44, lrate=0.010, error=0.202\n",
      "epoch=45, lrate=0.010, error=0.199\n",
      "epoch=46, lrate=0.010, error=0.196\n",
      "epoch=47, lrate=0.010, error=0.194\n",
      "epoch=48, lrate=0.010, error=0.191\n",
      "epoch=49, lrate=0.010, error=0.188\n",
      "epoch=50, lrate=0.010, error=0.186\n",
      "epoch=51, lrate=0.010, error=0.183\n",
      "epoch=52, lrate=0.010, error=0.181\n",
      "epoch=53, lrate=0.010, error=0.178\n",
      "epoch=54, lrate=0.010, error=0.176\n",
      "epoch=55, lrate=0.010, error=0.174\n",
      "epoch=56, lrate=0.010, error=0.171\n",
      "epoch=57, lrate=0.010, error=0.169\n",
      "epoch=58, lrate=0.010, error=0.167\n",
      "epoch=59, lrate=0.010, error=0.165\n",
      "epoch=60, lrate=0.010, error=0.163\n",
      "epoch=61, lrate=0.010, error=0.161\n",
      "epoch=62, lrate=0.010, error=0.159\n",
      "epoch=63, lrate=0.010, error=0.157\n",
      "epoch=64, lrate=0.010, error=0.155\n",
      "epoch=65, lrate=0.010, error=0.154\n",
      "epoch=66, lrate=0.010, error=0.152\n",
      "epoch=67, lrate=0.010, error=0.150\n",
      "epoch=68, lrate=0.010, error=0.149\n",
      "epoch=69, lrate=0.010, error=0.147\n",
      "epoch=70, lrate=0.010, error=0.145\n",
      "epoch=71, lrate=0.010, error=0.144\n",
      "epoch=72, lrate=0.010, error=0.142\n",
      "epoch=73, lrate=0.010, error=0.141\n",
      "epoch=74, lrate=0.010, error=0.140\n",
      "epoch=75, lrate=0.010, error=0.138\n",
      "epoch=76, lrate=0.010, error=0.137\n",
      "epoch=77, lrate=0.010, error=0.136\n",
      "epoch=78, lrate=0.010, error=0.134\n",
      "epoch=79, lrate=0.010, error=0.133\n",
      "epoch=80, lrate=0.010, error=0.132\n",
      "epoch=81, lrate=0.010, error=0.131\n",
      "epoch=82, lrate=0.010, error=0.129\n",
      "epoch=83, lrate=0.010, error=0.128\n",
      "epoch=84, lrate=0.010, error=0.127\n",
      "epoch=85, lrate=0.010, error=0.126\n",
      "epoch=86, lrate=0.010, error=0.125\n",
      "epoch=87, lrate=0.010, error=0.124\n",
      "epoch=88, lrate=0.010, error=0.123\n",
      "epoch=89, lrate=0.010, error=0.122\n",
      "epoch=90, lrate=0.010, error=0.121\n",
      "epoch=91, lrate=0.010, error=0.120\n",
      "epoch=92, lrate=0.010, error=0.119\n",
      "epoch=93, lrate=0.010, error=0.119\n",
      "epoch=94, lrate=0.010, error=0.118\n",
      "epoch=95, lrate=0.010, error=0.117\n",
      "epoch=96, lrate=0.010, error=0.116\n",
      "epoch=97, lrate=0.010, error=0.115\n",
      "epoch=98, lrate=0.010, error=0.115\n",
      "epoch=99, lrate=0.010, error=0.114\n",
      "epoch=100, lrate=0.010, error=0.113\n",
      "epoch=101, lrate=0.010, error=0.112\n",
      "epoch=102, lrate=0.010, error=0.112\n",
      "epoch=103, lrate=0.010, error=0.111\n",
      "epoch=104, lrate=0.010, error=0.110\n",
      "epoch=105, lrate=0.010, error=0.110\n",
      "epoch=106, lrate=0.010, error=0.109\n",
      "epoch=107, lrate=0.010, error=0.108\n",
      "epoch=108, lrate=0.010, error=0.108\n",
      "epoch=109, lrate=0.010, error=0.107\n",
      "epoch=110, lrate=0.010, error=0.107\n",
      "epoch=111, lrate=0.010, error=0.106\n",
      "epoch=112, lrate=0.010, error=0.106\n",
      "epoch=113, lrate=0.010, error=0.105\n",
      "epoch=114, lrate=0.010, error=0.105\n",
      "epoch=115, lrate=0.010, error=0.104\n",
      "epoch=116, lrate=0.010, error=0.104\n",
      "epoch=117, lrate=0.010, error=0.103\n",
      "epoch=118, lrate=0.010, error=0.103\n",
      "epoch=119, lrate=0.010, error=0.102\n",
      "epoch=120, lrate=0.010, error=0.102\n",
      "epoch=121, lrate=0.010, error=0.101\n",
      "epoch=122, lrate=0.010, error=0.101\n",
      "epoch=123, lrate=0.010, error=0.101\n",
      "epoch=124, lrate=0.010, error=0.100\n",
      "epoch=125, lrate=0.010, error=0.100\n",
      "epoch=126, lrate=0.010, error=0.099\n",
      "epoch=127, lrate=0.010, error=0.099\n",
      "epoch=128, lrate=0.010, error=0.099\n",
      "epoch=129, lrate=0.010, error=0.098\n",
      "epoch=130, lrate=0.010, error=0.098\n",
      "epoch=131, lrate=0.010, error=0.098\n",
      "epoch=132, lrate=0.010, error=0.097\n",
      "epoch=133, lrate=0.010, error=0.097\n",
      "epoch=134, lrate=0.010, error=0.097\n",
      "epoch=135, lrate=0.010, error=0.096\n",
      "epoch=136, lrate=0.010, error=0.096\n",
      "epoch=137, lrate=0.010, error=0.096\n",
      "epoch=138, lrate=0.010, error=0.095\n",
      "epoch=139, lrate=0.010, error=0.095\n",
      "epoch=140, lrate=0.010, error=0.095\n",
      "epoch=141, lrate=0.010, error=0.095\n",
      "epoch=142, lrate=0.010, error=0.094\n",
      "epoch=143, lrate=0.010, error=0.094\n",
      "epoch=144, lrate=0.010, error=0.094\n",
      "epoch=145, lrate=0.010, error=0.094\n",
      "epoch=146, lrate=0.010, error=0.093\n",
      "epoch=147, lrate=0.010, error=0.093\n",
      "epoch=148, lrate=0.010, error=0.093\n",
      "epoch=149, lrate=0.010, error=0.093\n"
     ]
    }
   ],
   "source": [
    "### Achar coeficientes pelo gradiente descendente\n",
    "l_rate = 0.01\n",
    "n_epoch = 150\n",
    "coefficients = coefficients_sgd(X_train, l_rate, n_epoch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "predictions = []\n",
    "for row in X_test:\n",
    "    predictions.append(predict(row, coefficients))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.39911672020461769,\n",
       " 0.40384475138726539,\n",
       " 0.41427230967358025,\n",
       " 0.43035849946542248,\n",
       " 0.43526887265487496,\n",
       " 0.43920178212965544,\n",
       " 0.43092171659199674,\n",
       " 0.37646981803985319,\n",
       " 0.41765576402305093,\n",
       " 0.4463405076048782,\n",
       " 0.44238055268075371,\n",
       " 0.41341602905827346,\n",
       " 0.38496584877119161,\n",
       " 0.40370387216125464,\n",
       " 0.43744326268425893,\n",
       " 0.45084935144314869,\n",
       " 0.36383913509624405,\n",
       " 0.38326110890819853,\n",
       " 0.38216977807331109,\n",
       " 0.41833086225195165,\n",
       " 0.41898184134012445,\n",
       " 0.3388817302261804,\n",
       " 0.42456442292086594,\n",
       " 0.36285236584118391,\n",
       " 0.4316425115586312,\n",
       " 0.38654085273337724,\n",
       " 0.38973469505766445,\n",
       " 0.40589255080478376,\n",
       " 0.40419598810053697,\n",
       " 0.36654680451875393,\n",
       " 0.4422318477325145,\n",
       " 0.40199609881284265,\n",
       " 0.38532223307125407,\n",
       " 0.36038904863463722,\n",
       " 0.40070074808618417,\n",
       " 0.37638619898678682,\n",
       " 0.42074243461907729,\n",
       " 0.39986904871608003,\n",
       " 0.39993972132866173,\n",
       " 0.3864680363304232,\n",
       " 0.45929996901336168,\n",
       " 0.39557795453438704,\n",
       " 0.41237497733831407,\n",
       " 0.43629375624377037,\n",
       " 0.39715984190380593,\n",
       " 0.38279877802676898,\n",
       " 0.44518286012286595,\n",
       " 0.36040494883990931,\n",
       " 0.4418188665077018,\n",
       " 0.42705333855638394,\n",
       " 0.37539368601451784,\n",
       " 0.41056336091705453,\n",
       " 0.3749608564944002,\n",
       " 0.39233072945230829,\n",
       " 0.44639718016079205,\n",
       " 0.41591391297178965,\n",
       " 0.40381783886328998,\n",
       " 0.40459834384511267,\n",
       " 0.37776475013186689,\n",
       " 0.45223854541996439,\n",
       " 0.43268417441791979,\n",
       " 0.39624702775171172,\n",
       " 0.34877691665893701,\n",
       " 0.38728136900901522,\n",
       " 0.40353670631003946,\n",
       " 0.40840908922912056,\n",
       " 0.39528216265486571,\n",
       " 0.41442390585200178,\n",
       " 0.41295483567682867,\n",
       " 0.39400289025216545,\n",
       " 0.41221455420689901,\n",
       " 0.42505287169753853,\n",
       " 0.40095560288904569,\n",
       " 0.39534367109061391,\n",
       " 0.41049605346810059,\n",
       " 0.38264140489035992,\n",
       " 0.42288099386825517,\n",
       " 0.41410752992667027,\n",
       " 0.38194468024375944,\n",
       " 0.41104819359716843,\n",
       " 0.4098136477369787,\n",
       " 0.40883577202341675,\n",
       " 0.41939110337061614,\n",
       " 0.41081833303315685,\n",
       " 0.3938869451700675,\n",
       " 0.43548622030159695,\n",
       " 0.39090768525226244,\n",
       " 0.38306934487513766,\n",
       " 0.38204076718867508,\n",
       " 0.4008590508187877,\n",
       " 0.39860718997343408,\n",
       " 0.39091388699151569,\n",
       " 0.41289455791355167,\n",
       " 0.42685611561101711,\n",
       " 0.37470612178770962,\n",
       " 0.44156324383642687,\n",
       " 0.45671305135861184,\n",
       " 0.42417215784875073,\n",
       " 0.42077864515280972,\n",
       " 0.40215727236417176,\n",
       " 0.42468366961785547,\n",
       " 0.40950632785386037,\n",
       " 0.40321074408955881,\n",
       " 0.37790057986353065,\n",
       " 0.35762019571592252,\n",
       " 0.39406495090991062,\n",
       " 0.37524014659735211,\n",
       " 0.38913150940937297,\n",
       " 0.4005301190638349,\n",
       " 0.39714916292501379,\n",
       " 0.4476322599931693,\n",
       " 0.37821856244061386,\n",
       " 0.39817110681313828,\n",
       " 0.40373381913735962,\n",
       " 0.40156077718999411,\n",
       " 0.38088674669020733,\n",
       " 0.39357390729077463,\n",
       " 0.39646536038186247,\n",
       " 0.42714955709204583,\n",
       " 0.37033901522748669,\n",
       " 0.38006243661776884,\n",
       " 0.39456167143141124,\n",
       " 0.38956256166623865,\n",
       " 0.42856189317165538,\n",
       " 0.4618289923066734,\n",
       " 0.37081137993514229,\n",
       " 0.36543879142716318,\n",
       " 0.38767048025658069,\n",
       " 0.40871901910510705,\n",
       " 0.4130726323110967,\n",
       " 0.39843864896410347,\n",
       " 0.40925594337442828,\n",
       " 0.47674231529974981,\n",
       " 0.40610098005279682,\n",
       " 0.41974714774561778,\n",
       " 0.39070172335259878,\n",
       " 0.38378719736423689,\n",
       " 0.4422318477325145,\n",
       " 0.40569693341630791,\n",
       " 0.42660242593807973,\n",
       " 0.37014889865353634,\n",
       " 0.42827618339751311,\n",
       " 0.37359623685767906,\n",
       " 0.39314323329321454,\n",
       " 0.40336861204193092,\n",
       " 0.38678069028048673,\n",
       " 0.46725720660314179,\n",
       " 0.36516390628787465,\n",
       " 0.40964652879587771,\n",
       " 0.41096495895901275,\n",
       " 0.40850280154895918,\n",
       " 0.41794804112038358,\n",
       " 0.39841782179685598,\n",
       " 0.41963114665274187,\n",
       " 0.39962923831935293,\n",
       " 0.42904643584362606,\n",
       " 0.41898184134012445,\n",
       " 0.42007399147474156,\n",
       " 0.40622002715599831,\n",
       " 0.40137794515098152,\n",
       " 0.34595622273936244,\n",
       " 0.3972367960827583,\n",
       " 0.41692660199470588,\n",
       " 0.41410024034121778,\n",
       " 0.38248361669230313,\n",
       " 0.37003427164072922,\n",
       " 0.39687664738185463,\n",
       " 0.40898716608333802,\n",
       " 0.40422786491327539,\n",
       " 0.37536113671977028,\n",
       " 0.39279648963743846,\n",
       " 0.37294701773176386,\n",
       " 0.37691730966198067,\n",
       " 0.37416425014617416,\n",
       " 0.39396529290870452,\n",
       " 0.43685833471648461,\n",
       " 0.39931573029509165,\n",
       " 0.42893679265351464,\n",
       " 0.37733498738228688,\n",
       " 0.39007187982812119,\n",
       " 0.40955751541775665,\n",
       " 0.43022299087065563,\n",
       " 0.40428066510376404,\n",
       " 0.42765714703831242,\n",
       " 0.37276773177234862,\n",
       " 0.41777223908193051,\n",
       " 0.43007870987645036,\n",
       " 0.38472907547953555,\n",
       " 0.38164344724397847,\n",
       " 0.38269240731854026,\n",
       " 0.4100087283142097,\n",
       " 0.43881823849208074,\n",
       " 0.41295483567682867,\n",
       " 0.37952207249518499,\n",
       " 0.42471865427929933,\n",
       " 0.38474187122292974,\n",
       " 0.37531825147704329,\n",
       " 0.40485809975695347,\n",
       " 0.39553975045485784,\n",
       " 0.40839953421727082,\n",
       " 0.3710172871047428,\n",
       " 0.39454157418629349,\n",
       " 0.4594758139036077,\n",
       " 0.41461232004593629,\n",
       " 0.42019079263944376,\n",
       " 0.3786131174521708,\n",
       " 0.42944215074784237,\n",
       " 0.43027863141054173,\n",
       " 0.42604163109376342,\n",
       " 0.41352936178940669,\n",
       " 0.41779020102677356,\n",
       " 0.39531404064255343,\n",
       " 0.42848135911549112,\n",
       " 0.44558173794356604,\n",
       " 0.38948049127190959,\n",
       " 0.43706501230031236,\n",
       " 0.38844970390510758,\n",
       " 0.44658041428369744,\n",
       " 0.4198118097515699,\n",
       " 0.39556454968867349,\n",
       " 0.41820821899904193,\n",
       " 0.44122384280365728,\n",
       " 0.36193974860847783,\n",
       " 0.39091388699151569,\n",
       " 0.4145642179683951,\n",
       " 0.39981939650151721,\n",
       " 0.44015173349004644,\n",
       " 0.39070643286674667,\n",
       " 0.3939684485309175,\n",
       " 0.39500942854475463,\n",
       " 0.40481879032728674,\n",
       " 0.4087054561650203,\n",
       " 0.39269904293376362,\n",
       " 0.40598653796205192,\n",
       " 0.37571997292694415,\n",
       " 0.36712467655147057,\n",
       " 0.37609400752801192,\n",
       " 0.41286944823460869,\n",
       " 0.39880241296339952,\n",
       " 0.37295536751572222,\n",
       " 0.41228952271235764,\n",
       " 0.39317430771873746,\n",
       " 0.42709634629910537,\n",
       " 0.38989513717274255,\n",
       " 0.39952320967690047,\n",
       " 0.40533299763856701,\n",
       " 0.3920223095499058,\n",
       " 0.41795414831423333,\n",
       " 0.37006931376731161,\n",
       " 0.41042883349941567,\n",
       " 0.4201451364676857,\n",
       " 0.38610193283438998,\n",
       " 0.38599645293985391,\n",
       " 0.41048200156254222,\n",
       " 0.40644771378030398,\n",
       " 0.40450889728682465,\n",
       " 0.38377992368572938,\n",
       " 0.35993651877274441,\n",
       " 0.43160017530613459,\n",
       " 0.39458677055148866,\n",
       " 0.39803595832073274,\n",
       " 0.41765576402305093,\n",
       " 0.42606783974982781,\n",
       " 0.38504998821974212,\n",
       " 0.402763468754673,\n",
       " 0.39928337220373844,\n",
       " 0.36551622032800357,\n",
       " 0.35715605313885196,\n",
       " 0.4046698102392991,\n",
       " 0.38812948754785342,\n",
       " 0.39218670822530288,\n",
       " 0.40060986002868321,\n",
       " 0.44509063931445447,\n",
       " 0.37968227968993062,\n",
       " 0.43282933990031164,\n",
       " 0.41847550883667456,\n",
       " 0.40259586514457757,\n",
       " 0.43666477329501474,\n",
       " 0.35207335133205642,\n",
       " 0.38149875576061426,\n",
       " 0.44347047440438447,\n",
       " 0.4067919153073058,\n",
       " 0.40334496402027742,\n",
       " 0.42131294553918219,\n",
       " 0.3891589928729885,\n",
       " 0.38893773727633535,\n",
       " 0.37052092941615949,\n",
       " 0.42813736500090976,\n",
       " 0.38491778994536296,\n",
       " 0.43130720856499405,\n",
       " 0.38196571179453936,\n",
       " 0.3396900684433366,\n",
       " 0.38751086614376823,\n",
       " 0.38209593726303948,\n",
       " 0.38611202322514349,\n",
       " 0.40992269228201178,\n",
       " 0.37983160868584193,\n",
       " 0.40028260323660114,\n",
       " 0.38770673623745877,\n",
       " 0.43079396355701183,\n",
       " 0.3602858588769613,\n",
       " 0.44497024322320045,\n",
       " 0.38503750461974323,\n",
       " 0.38268127939524915,\n",
       " 0.40718675615470273,\n",
       " 0.40556797223666446,\n",
       " 0.37791785929507993,\n",
       " 0.40937993666751621,\n",
       " 0.38471714390425954,\n",
       " 0.45460754196730591,\n",
       " 0.41034555166010667,\n",
       " 0.43603477135512708,\n",
       " 0.4106652052976143,\n",
       " 0.38231722494638148,\n",
       " 0.43355433158544487,\n",
       " 0.37541768382883806,\n",
       " 0.33701409205055405,\n",
       " 0.43703236186322664,\n",
       " 0.39101553655825355,\n",
       " 0.3598032142832232,\n",
       " 0.4296673896883193,\n",
       " 0.34939542156379783,\n",
       " 0.38299715822846209,\n",
       " 0.45072633426030556,\n",
       " 0.42635434886747681,\n",
       " 0.3840234854868787,\n",
       " 0.45041628893324176,\n",
       " 0.39333010525764067,\n",
       " 0.41320595902428287,\n",
       " 0.3396900684433366,\n",
       " 0.40599943791103427,\n",
       " 0.40167148854988288,\n",
       " 0.41105420224137967,\n",
       " 0.41347912883164045,\n",
       " 0.39408230849868897,\n",
       " 0.39316812035754328,\n",
       " 0.38577595762922201,\n",
       " 0.44331754695282954,\n",
       " 0.41134557223455048,\n",
       " 0.44665451864703348,\n",
       " 0.3928707579706594,\n",
       " 0.37810027558316622,\n",
       " 0.3943248367068361,\n",
       " 0.41158817463833031,\n",
       " 0.41188588147564059,\n",
       " 0.43121583558220106,\n",
       " 0.40013991535365329,\n",
       " 0.4147035279896823,\n",
       " 0.39456624364196036,\n",
       " 0.38138435609229215,\n",
       " 0.39227766015280302,\n",
       " 0.42346692625412524,\n",
       " 0.40760191397493645,\n",
       " 0.3944605105835397,\n",
       " 0.4181270063113417,\n",
       " 0.40787370339895102,\n",
       " 0.40955751541775665,\n",
       " 0.40336249312864525,\n",
       " 0.39824646948557835,\n",
       " 0.35471773851464872,\n",
       " 0.39029200468213665,\n",
       " 0.45471125991032008,\n",
       " 0.41514959724947037,\n",
       " 0.45227957010185904,\n",
       " 0.41127967408618793,\n",
       " 0.39912987706603076,\n",
       " 0.36681509322404976,\n",
       " 0.45539843867335267,\n",
       " 0.34107138489428018,\n",
       " 0.38131796281185842,\n",
       " 0.40049722368402585,\n",
       " 0.39651397139063177,\n",
       " 0.38220898044643198,\n",
       " 0.37464948614522975,\n",
       " 0.43247882673354565,\n",
       " 0.42228106802899729,\n",
       " 0.43458520602313444,\n",
       " 0.40615019213069042,\n",
       " 0.39924324116670418,\n",
       " 0.40854252697751081,\n",
       " 0.40720412026757369,\n",
       " 0.41821879473492901,\n",
       " 0.39998665210304529,\n",
       " 0.40292758829270292,\n",
       " 0.42332809937501015,\n",
       " 0.4046128890550128,\n",
       " 0.4450891590937735,\n",
       " 0.38871165836641652,\n",
       " 0.38210624782573355,\n",
       " 0.40838900467519085,\n",
       " 0.39981939650151721,\n",
       " 0.40329357033512736,\n",
       " 0.3711289899922886,\n",
       " 0.3874829644274092,\n",
       " 0.40980819436961918,\n",
       " 0.37343136367048446,\n",
       " 0.3964372353347082,\n",
       " 0.37009233382880286,\n",
       " 0.37429388519734047,\n",
       " 0.35635135364995241,\n",
       " 0.37829810227209654,\n",
       " 0.43479733847328972,\n",
       " 0.37808418712242542,\n",
       " 0.36041506447414351,\n",
       " 0.37630531488736019,\n",
       " 0.38610193283438998,\n",
       " 0.46891342307685846,\n",
       " 0.4080659311898886,\n",
       " 0.40290339508341072,\n",
       " 0.42360447291258246,\n",
       " 0.4006252756760017,\n",
       " 0.42146984592456094,\n",
       " 0.38949437504414397,\n",
       " 0.45796161334809526,\n",
       " 0.41065426812427896,\n",
       " 0.43794124991399003,\n",
       " 0.40993780654075629,\n",
       " 0.39674858707320754,\n",
       " 0.42627016041697396,\n",
       " 0.40410198153125487,\n",
       " 0.4330615222444415,\n",
       " 0.37858469756831714,\n",
       " 0.35949153158831626,\n",
       " 0.34401461803743794,\n",
       " 0.36928520246626295,\n",
       " 0.38453267566654259,\n",
       " 0.37633888782852326,\n",
       " 0.3749608564944002,\n",
       " 0.41347912883164045,\n",
       " 0.43901955450456326,\n",
       " 0.39750137734745922,\n",
       " 0.41096807482188763,\n",
       " 0.42266206782189636,\n",
       " 0.37099750133958909,\n",
       " 0.39803581350828987,\n",
       " 0.38580819507524627,\n",
       " 0.37804124059296623,\n",
       " 0.38434311557623929,\n",
       " 0.3601972277610217,\n",
       " 0.36336621249273648,\n",
       " 0.39675643739087635,\n",
       " 0.40134992654614354,\n",
       " 0.42377566491307139,\n",
       " 0.40630760902780005,\n",
       " 0.39602840254407295,\n",
       " 0.39496116178314761,\n",
       " 0.41403805477058558,\n",
       " 0.40444224264042977,\n",
       " 0.41431546625630195,\n",
       " 0.395541364477135,\n",
       " 0.44814832666268434,\n",
       " 0.39070643286674667,\n",
       " 0.43271536347998973,\n",
       " 0.38671531201854553,\n",
       " 0.42009468551805457,\n",
       " 0.42254699868589535,\n",
       " 0.39049122263507702,\n",
       " 0.39336927972564334,\n",
       " 0.45400367249668405,\n",
       " 0.39924511882471769,\n",
       " 0.38865082591420969,\n",
       " 0.40153070090331311,\n",
       " 0.37788095372461855,\n",
       " 0.38738751875931698,\n",
       " 0.41593152241345444,\n",
       " 0.389609404225502,\n",
       " 0.4198357398275514,\n",
       " 0.45619171393031682,\n",
       " 0.41681300851783448,\n",
       " 0.42046326127316475,\n",
       " 0.37325469003667749,\n",
       " 0.42480980204165408,\n",
       " 0.41799901631488889,\n",
       " 0.43912975691915157,\n",
       " 0.39300531668135807,\n",
       " 0.37691730966198067,\n",
       " 0.40200813707850303,\n",
       " 0.38860282836618676,\n",
       " 0.3669673236256154,\n",
       " 0.44373278388253851,\n",
       " 0.47603181551262619,\n",
       " 0.37962509039844355,\n",
       " 0.42304608808147109,\n",
       " 0.40113609741544115,\n",
       " 0.40070074808618417,\n",
       " 0.42442831610782705,\n",
       " 0.43337693900672269,\n",
       " 0.38766831899051618,\n",
       " 0.39998948123325584,\n",
       " 0.40751306375089158,\n",
       " 0.40053560064496557,\n",
       " 0.38130217584650555,\n",
       " 0.37201608672922548,\n",
       " 0.38981697164437812,\n",
       " 0.3867715692882846,\n",
       " 0.38740011294363275,\n",
       " 0.38766839692289667,\n",
       " 0.37723648230649348,\n",
       " 0.36193974860847783,\n",
       " 0.41718341378411034,\n",
       " 0.42396394389533898,\n",
       " 0.40292612922933346,\n",
       " 0.38403933578017341,\n",
       " 0.43108360171598026,\n",
       " 0.38336653466089021,\n",
       " 0.39904110984271973,\n",
       " 0.39862274710206497,\n",
       " 0.40460841507041428,\n",
       " 0.38905475626511538,\n",
       " 0.41502992060749216,\n",
       " 0.44073942827273305,\n",
       " 0.36884954127591718,\n",
       " 0.35794081979005749,\n",
       " 0.38183522456910646,\n",
       " 0.40611270123242077,\n",
       " 0.42236768913775435,\n",
       " 0.37792786926614336,\n",
       " 0.36688403815294274,\n",
       " 0.41791992562969932,\n",
       " 0.40580619160481474,\n",
       " 0.38362197526525188,\n",
       " 0.42237517331246105,\n",
       " 0.40957737906356573,\n",
       " 0.36696240121104512,\n",
       " 0.37338364777162636,\n",
       " 0.40946980489120766,\n",
       " 0.36846711347323735,\n",
       " 0.38871569712568582,\n",
       " 0.42432835211189263,\n",
       " 0.43371046025685911,\n",
       " 0.37191315884929671,\n",
       " 0.40457962765909294,\n",
       " 0.4287621931411118,\n",
       " 0.37874446597981837,\n",
       " 0.34926784582545883,\n",
       " 0.41796968020244957,\n",
       " 0.35819366269192593,\n",
       " 0.424957272551716,\n",
       " 0.36131640939191284,\n",
       " 0.42584194103984752,\n",
       " 0.39835891205426566,\n",
       " 0.38856420079439447,\n",
       " 0.43449481119215227,\n",
       " 0.36245470051115436,\n",
       " 0.37624027009102745,\n",
       " 0.39386282395338934,\n",
       " 0.39909981034087122,\n",
       " 0.40356019924571407,\n",
       " 0.38038635248833624,\n",
       " 0.38256077176696174,\n",
       " 0.37887131557438075,\n",
       " 0.43679821448569545,\n",
       " 0.36024395461056491,\n",
       " 0.40924041454137355,\n",
       " 0.35229488964228406,\n",
       " 0.37316124046152221,\n",
       " 0.39587752090203393,\n",
       " 0.37321581121499992,\n",
       " 0.38887751840216006,\n",
       " 0.40147534057942352,\n",
       " 0.44813976548480727,\n",
       " 0.36859121677101248,\n",
       " 0.35779789172050463,\n",
       " 0.42910421270543037,\n",
       " 0.41457083750257034,\n",
       " 0.3906100497279611,\n",
       " 0.42333707404966175,\n",
       " 0.4043849435902977,\n",
       " 0.37892417618974145,\n",
       " 0.40933513202080213,\n",
       " 0.39806835156007503,\n",
       " 0.40255605323551075,\n",
       " 0.39539955164786145,\n",
       " 0.39279648963743846,\n",
       " 0.41453160856061089,\n",
       " 0.40179138842740153,\n",
       " 0.43924818441539476,\n",
       " 0.4481296190312441,\n",
       " 0.36101066847407787,\n",
       " 0.39131183477155373,\n",
       " 0.36101066847407787,\n",
       " 0.3934944133593542,\n",
       " 0.36890745096631866,\n",
       " 0.4015034038786674,\n",
       " 0.39677951290819274,\n",
       " 0.42764235994899269,\n",
       " 0.40003127598027671,\n",
       " 0.4023155124345274,\n",
       " 0.41232029944157139,\n",
       " 0.37325469003667749,\n",
       " 0.39677951290819274,\n",
       " 0.37314347559953875,\n",
       " 0.48683877058330272,\n",
       " 0.44789192346529338,\n",
       " 0.3944145672867565,\n",
       " 0.42454714268453192,\n",
       " 0.39984780218466548,\n",
       " 0.39623179458197477,\n",
       " 0.43374079464482024,\n",
       " 0.4370089132173165,\n",
       " 0.40268866112640023,\n",
       " 0.36904851812277784,\n",
       " 0.365487702478549,\n",
       " 0.42722067527895546,\n",
       " 0.37790057986353065,\n",
       " 0.45508691243255028,\n",
       " 0.43334109402619136,\n",
       " 0.40471165199759868,\n",
       " 0.42495928800075777,\n",
       " 0.45445669032915792,\n",
       " 0.38905196841919898,\n",
       " 0.40278578125599618,\n",
       " 0.39253590233541513,\n",
       " 0.41745069010940772,\n",
       " 0.43904485706095758,\n",
       " 0.39633367681185055,\n",
       " 0.37632450103736692,\n",
       " 0.34926784582545883,\n",
       " 0.36392783222281266,\n",
       " 0.3807693039048361,\n",
       " 0.35000549551240784,\n",
       " 0.44814832666268434,\n",
       " 0.37887301034081966,\n",
       " 0.3712742363504411,\n",
       " 0.40125246896528238,\n",
       " 0.39178646415340745,\n",
       " 0.44730298128588725,\n",
       " 0.39640681283709045,\n",
       " 0.3684484206016248,\n",
       " 0.40630993030891621,\n",
       " 0.36825314610142046,\n",
       " 0.40963103475504187,\n",
       " 0.4248905049507577,\n",
       " 0.38155223098050617,\n",
       " 0.43420138082023746,\n",
       " 0.45416402698855513,\n",
       " 0.42111331611398256,\n",
       " 0.37650877523030812,\n",
       " 0.43346181820007568,\n",
       " 0.40113609741544115,\n",
       " 0.40975300989905505,\n",
       " 0.42614012719037403,\n",
       " 0.40446413564985217,\n",
       " 0.40599943791103427,\n",
       " 0.42364481522674208,\n",
       " 0.40987820333933112,\n",
       " 0.39920142369632883,\n",
       " 0.37556896462805639,\n",
       " 0.39850327450438189,\n",
       " 0.38578064835741666,\n",
       " 0.39651361680218905,\n",
       " 0.38087202166306899,\n",
       " 0.41164981899767517,\n",
       " 0.4098262526351607,\n",
       " 0.43552677617962421,\n",
       " 0.40534593898166116,\n",
       " 0.38360753284088217,\n",
       " 0.4076210736687676,\n",
       " 0.4207769746529979,\n",
       " 0.39599739225603536,\n",
       " 0.4153517198458051,\n",
       " 0.39347377396140265,\n",
       " 0.39168512387183368,\n",
       " 0.39096009345768867,\n",
       " 0.38459775771664734,\n",
       " 0.41245761687527388,\n",
       " 0.39365314210842872,\n",
       " 0.38359966402887408,\n",
       " 0.40544004049294358,\n",
       " 0.40942714445136147,\n",
       " 0.3823529602027585,\n",
       " 0.4105243197563414,\n",
       " 0.38186885319537628,\n",
       " 0.422188919104305,\n",
       " 0.40222826455743177,\n",
       " 0.41558124407518587,\n",
       " 0.43016234011484417,\n",
       " 0.37548633546190346,\n",
       " 0.37359623685767906,\n",
       " 0.38597462198227722,\n",
       " 0.36910041439015029,\n",
       " 0.35142106241849458,\n",
       " 0.38414414021707194,\n",
       " 0.41102081264228602,\n",
       " 0.42019925366956568,\n",
       " 0.40880561451680175,\n",
       " 0.38557473047739688,\n",
       " 0.4112219909089565,\n",
       " 0.40015316740785473,\n",
       " 0.41821879473492901,\n",
       " 0.38222335543588698,\n",
       " 0.40509350788969123,\n",
       " 0.40005005623795747,\n",
       " 0.42356304558382957,\n",
       " 0.40218358459786818,\n",
       " 0.38145974969569219,\n",
       " 0.39878354246098618,\n",
       " 0.44458156722573089,\n",
       " 0.40777886191139234,\n",
       " 0.43917418419751048,\n",
       " 0.35836092092195138,\n",
       " 0.42388124391831244,\n",
       " 0.43861444442869618,\n",
       " 0.38306502568685863,\n",
       " 0.38766839692289667,\n",
       " 0.38996103583951397,\n",
       " 0.38949339960988066,\n",
       " 0.36542186531769849,\n",
       " 0.4110972937823133,\n",
       " 0.40106729667359708,\n",
       " 0.37040326064740653,\n",
       " 0.41353474227436798,\n",
       " 0.46251077296695803,\n",
       " 0.38623191443840293,\n",
       " 0.39013487735985791,\n",
       " 0.36814433996486962,\n",
       " 0.41791228652357026,\n",
       " 0.4081075108115152,\n",
       " 0.33563810787841514,\n",
       " 0.41390748615928868,\n",
       " 0.38282336472697326,\n",
       " 0.38148817841593058,\n",
       " 0.43139299729864217,\n",
       " 0.40427097161058251,\n",
       " 0.4134748895609951,\n",
       " 0.39568162208685675,\n",
       " 0.41540401275256894,\n",
       " 0.39403228956312025,\n",
       " 0.40667922745396595,\n",
       " 0.39332073926341266,\n",
       " 0.40179138842740153,\n",
       " 0.39156346417516452,\n",
       " 0.4454191475990773,\n",
       " 0.40681985655280173,\n",
       " 0.41310303638632717,\n",
       " 0.4452682108129713,\n",
       " 0.38972686214340901,\n",
       " 0.4310203909147346,\n",
       " 0.40974937966545294,\n",
       " 0.38968279706681741,\n",
       " 0.39315772370830449,\n",
       " 0.36928520246626295,\n",
       " 0.38006243661776884,\n",
       " 0.38450363196180221,\n",
       " 0.40773259917069782,\n",
       " 0.42974292560631366,\n",
       " 0.3923080750346124,\n",
       " 0.40102873389145061,\n",
       " 0.39283813062274092,\n",
       " 0.41446938383118459,\n",
       " 0.38071113854612881,\n",
       " 0.41051415154864529,\n",
       " 0.41180715005396035,\n",
       " 0.39577082102384031,\n",
       " 0.42450376172176041,\n",
       " 0.42664159956925973,\n",
       " 0.36861661512392768,\n",
       " 0.37090891623990657,\n",
       " 0.37729779746070963,\n",
       " 0.43451111859692415,\n",
       " 0.39697402914491442,\n",
       " 0.39899059492645211,\n",
       " 0.40078405714319598,\n",
       " 0.4118788040001522,\n",
       " 0.37510510745606057,\n",
       " 0.4139555356284485,\n",
       " 0.43202312094315898,\n",
       " 0.4324500055186542,\n",
       " 0.3969759733270169,\n",
       " 0.42296745969601979,\n",
       " 0.43437600554269779,\n",
       " 0.42474621861650996,\n",
       " 0.40124636527456425,\n",
       " 0.44242748865499737,\n",
       " 0.35706652712982773,\n",
       " 0.39397098561180138,\n",
       " 0.40180594397272834,\n",
       " 0.41549777306347419,\n",
       " 0.41158662354161474,\n",
       " 0.40485143347680896,\n",
       " 0.42567436636779099,\n",
       " 0.3932656638005379,\n",
       " 0.41770993006138257,\n",
       " 0.3677622371212374,\n",
       " 0.41382347570409783,\n",
       " 0.4214714638056577,\n",
       " 0.44311981864718869,\n",
       " 0.42315636122915723,\n",
       " 0.47427639119898618,\n",
       " 0.39914915646087767,\n",
       " 0.37857030742789077,\n",
       " 0.4070433697145952,\n",
       " 0.39068219363015372,\n",
       " 0.38421374217958498,\n",
       " 0.45199836761164214,\n",
       " 0.39619448292574888,\n",
       " 0.41084377862612187,\n",
       " 0.40509350788969123,\n",
       " 0.39886273373300185,\n",
       " 0.40503803201831345,\n",
       " 0.4156931703705054,\n",
       " 0.40876658836147639,\n",
       " 0.39987247436709539,\n",
       " 0.43675844741599179,\n",
       " 0.39083311843401153,\n",
       " 0.39330767956614282,\n",
       " 0.43819244212606262,\n",
       " 0.39019820225089513,\n",
       " 0.39645203159857101,\n",
       " 0.42438398655033616,\n",
       " 0.41032019551983812,\n",
       " 0.38834482508016255,\n",
       " 0.3704241750889215,\n",
       " 0.43641348858185081,\n",
       " 0.37938128477655325,\n",
       " 0.38006243661776884,\n",
       " 0.3749608564944002,\n",
       " 0.39512602424561527,\n",
       " 0.38700276071623041,\n",
       " 0.38700961085650593,\n",
       " 0.38815520076460175,\n",
       " 0.39628792711325089,\n",
       " 0.40398657848665837,\n",
       " 0.41357275589330639,\n",
       " 0.43924818441539476,\n",
       " 0.40825457361357009,\n",
       " 0.38817444667752043,\n",
       " 0.41785855374923597,\n",
       " 0.38678028360760752,\n",
       " 0.39654385233041889,\n",
       " 0.43647273696111349,\n",
       " 0.34373403187490792,\n",
       " 0.41349934078720957,\n",
       " 0.39909981034087122,\n",
       " 0.39884467067148882,\n",
       " 0.43677445883624499,\n",
       " 0.3820602478593752,\n",
       " 0.39932807553679306,\n",
       " 0.39748636177643937,\n",
       " 0.41761389227524209,\n",
       " 0.35167806943284985,\n",
       " 0.45115652320408783,\n",
       " 0.39518954902407721,\n",
       " 0.44417779152861608,\n",
       " 0.42659128153542064,\n",
       " 0.46101046559080372,\n",
       " 0.43377463642274006,\n",
       " 0.42454236429543141,\n",
       " 0.46760945476775306,\n",
       " 0.43566731565702232,\n",
       " 0.42458951026073294,\n",
       " 0.37783841645974869,\n",
       " 0.40046969205596566,\n",
       " 0.37598616335466067,\n",
       " 0.38096468654614535,\n",
       " 0.44073942827273305,\n",
       " 0.36717783962029982,\n",
       " 0.40061555876685567,\n",
       " 0.41329652915162962,\n",
       " 0.36132307013910425,\n",
       " 0.41829186716170463,\n",
       " 0.39186750160559525,\n",
       " 0.40260000357528819,\n",
       " 0.3972367960827583,\n",
       " 0.37493950959029987,\n",
       " 0.37152954390775478,\n",
       " 0.41697259061929165,\n",
       " 0.41983201427459882,\n",
       " 0.46817996291440106,\n",
       " 0.41005368488052829,\n",
       " 0.39446808205849831,\n",
       " 0.36803831937891768,\n",
       " 0.35824907320811777,\n",
       " 0.36881917072377207,\n",
       " 0.42883915770404912,\n",
       " 0.44338531014829879,\n",
       " 0.43950905147419461,\n",
       " 0.4424254035761751,\n",
       " 0.38087957695750607,\n",
       " 0.40336249312864525,\n",
       " 0.39012802014154346,\n",
       " 0.3959571248805438,\n",
       " 0.38283186347129433,\n",
       " 0.47365217932040227,\n",
       " 0.40878885943585597,\n",
       " 0.38551648315534515,\n",
       " 0.44067565426034339,\n",
       " 0.38008015408669582,\n",
       " 0.42707592731260902,\n",
       " 0.36338693615862505,\n",
       " 0.37359623685767906,\n",
       " 0.41964341753559742,\n",
       " 0.39494518717875093,\n",
       " 0.4261686146609307,\n",
       " 0.37897505147740596,\n",
       " 0.41038843619019338,\n",
       " 0.41081123777360845,\n",
       " 0.45163777955844359,\n",
       " 0.38599645293985391,\n",
       " 0.41670857617010831,\n",
       " 0.37897985434686471,\n",
       " 0.41257349004570143,\n",
       " 0.41920838703707802,\n",
       " 0.36997941397808104,\n",
       " 0.41065426812427896,\n",
       " 0.40409987339351078,\n",
       " 0.42780593973779996,\n",
       " 0.3949791446072341,\n",
       " 0.3811593636045702,\n",
       " 0.38324585125242461,\n",
       " 0.38111085069592271,\n",
       " 0.40569693341630791,\n",
       " 0.37751480751649447,\n",
       " 0.41168047806126939,\n",
       " 0.37997917656468982,\n",
       " 0.40925384956092553,\n",
       " 0.40236469586341306,\n",
       " 0.42880452009430858,\n",
       " 0.38826322423254089,\n",
       " 0.38780095605941817,\n",
       " 0.40878113591640058,\n",
       " 0.40576591348514729,\n",
       " 0.46215194664238735,\n",
       " 0.40878113591640058,\n",
       " 0.37986355271601807,\n",
       " 0.41209583575168468,\n",
       " 0.43178928562309121,\n",
       " 0.40875932567205631,\n",
       " 0.40060492077429988,\n",
       " 0.41427994747224894,\n",
       " 0.4204489046925961,\n",
       " 0.40191914586365096,\n",
       " 0.43026990103006191,\n",
       " 0.3870352074876422,\n",
       " 0.4378866894442382,\n",
       " 0.38169675954756421,\n",
       " 0.44212920671578915,\n",
       " 0.41926548398265878,\n",
       " 0.39192540274441745,\n",
       " 0.35921585027616565,\n",
       " 0.40375486957293866,\n",
       " 0.40008123023967163,\n",
       " 0.40457042506960217,\n",
       " 0.40120999455442119,\n",
       " 0.40291921754672611,\n",
       " 0.37622528679886635,\n",
       " 0.4074663794303251,\n",
       " 0.38472907547953555,\n",
       " 0.42138365387021903,\n",
       " 0.42829244851985387,\n",
       " 0.36773271420110076,\n",
       " 0.40998971397762879,\n",
       " 0.39259050732909323,\n",
       " 0.38288945950697045,\n",
       " 0.37216243687231709,\n",
       " 0.41341326553260016,\n",
       " 0.44569761066136165,\n",
       " 0.39998948123325584,\n",
       " 0.41341326553260016,\n",
       " 0.42895632630125669,\n",
       " 0.37351006955861621,\n",
       " 0.43698485836316947,\n",
       " 0.39053663368145608,\n",
       " 0.39226844635297242,\n",
       " 0.40820928348547042,\n",
       " 0.41169978131807011,\n",
       " 0.42744864243055275,\n",
       " 0.33196653430029499,\n",
       " 0.41724130380426278,\n",
       " 0.43351832669446944,\n",
       " 0.40686248087876314,\n",
       " 0.3897369723691177,\n",
       " 0.3955447713957389,\n",
       " 0.37858962759049009,\n",
       " 0.39180759115277691,\n",
       " 0.39210695624918734,\n",
       " 0.37834308512534021,\n",
       " 0.41709970814681241,\n",
       " 0.38182657886673455,\n",
       " 0.40477114606299458,\n",
       " 0.39439226868376565,\n",
       " 0.37804027160421949,\n",
       " 0.3396900684433366,\n",
       " 0.40138931234700004,\n",
       " 0.40502806725224966,\n",
       " 0.43081074163699057,\n",
       " 0.38247719275684605,\n",
       " 0.39159956076627084,\n",
       " 0.41681667682867152,\n",
       " 0.38177711459421243,\n",
       " 0.42059449872500038,\n",
       " 0.40514099157055283,\n",
       " 0.43103136256152064,\n",
       " 0.38948049127190959,\n",
       " 0.42735842918254019,\n",
       " 0.40196368047345421,\n",
       " 0.38305021067401801,\n",
       " 0.39309503483023539,\n",
       " 0.45842232086887841,\n",
       " 0.3923635920090941,\n",
       " ...]"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "predictions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
